package com.lubase.metadata.invoke;

import com.lubase.core.extend.IInvokeMethod;
import com.lubase.metadata.model.EModelType;
import com.lubase.metadata.service.RelationMapService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;

@Component
public class getRelationMapByDatabase implements IInvokeMethod {
    @Autowired
    RelationMapService relationMapService;

    @Override
    public Object exe(HashMap<String, String> mapParam) throws Exception {
        String databaseId = checkAndGetParam("databaseId", mapParam);
        Integer modelType = Integer.parseInt(checkAndGetParam("modelType", mapParam));
        return relationMapService.getTableRelationMapOfDatabase(databaseId, EModelType.getType(modelType));
    }

    @Override
    public String getDescription() {
        return "获取ER图：根据数据库ID";
    }

    @Override
    public String getId() {
        return "1473031921444327424";
    }
}
